﻿@model IEnumerable<RedSand.Site.Models.ProductTabInfo>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>
<script type="text/javascript">
    $(function () {
        $("#tabs").tabs().show();
        $('#tabs ul:first .ui-icon-pencil').click(function () {
            var index = $('#tabs ul:first .ui-icon-pencil').index(this);
            $.cookie('product-tab-index', index);
            $("#tabs").tabs("select", index);
        });
    });
</script>
<div id="tabs" style="display:none; min-height:300px">
    <ul>
        @if (Model != null)
        {
            for (int i = 1; i <= Model.Count(); i++)
            {
                <li>
                    <a href="#tabs-@i">@Model.ElementAt(i-1).Title</a> 
                    @Ajax.ActionLink("Sửa", "editTab", new { id = Model.ElementAt(i - 1).TabID }, new AjaxOptions { UpdateTargetId = "tab-edit-wrap", LoadingElementId = "loading-panel", OnSuccess = "edit_tab_click", OnFailure = "ajax_failure" }, new { @class = "ui-icon ui-icon-pencil" })
                    @Ajax.ActionLink("Xóa", "deleteTab", new { id = Model.ElementAt(i - 1).TabID, pid = Model.ElementAt(i - 1).ProductID }, new AjaxOptions { UpdateTargetId = "tabs-wrap", LoadingElementId = "loading-panel", OnFailure = "ajax_failure", Confirm = "Bạn có chắc chắn muốn xóa?" }, new { @class = "ui-icon ui-icon-close" })
                </li>
            }
        }
    </ul>
    @if (Model != null)
    {
        for (int i = 1; i <= Model.Count(); i++)
        {
            <div id="tabs-@i">
                @Html.Raw(Model.ElementAt(i - 1).Content)
            </div>
        }
    }
</div>
